﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OnlineStore.Dal;

namespace OnlineStore.Bll
{
    public class bizUser
    {
        DalUser _dalUser = new DalUser();
        public bizUser() { }
        public tbCustomer getUser(string UserName)
        {
            return _dalUser.User(UserName);
        }
        public tbCustomer UpdateInfo(tbCustomer user,string FullName,string Address,string Tel)
        {
            FullName = FullName.Trim();
            Address = Address.Trim();
            Tel = Tel.Trim();
            if (Convert.ToInt32(Tel) == 0)
                return null;
            return _dalUser.UpdateInfo(user, FullName, Address, Tel);
        }
        public tbCustomer UpdatePassWord(tbCustomer user, string PassWordNow, string PassWordNew)
        {
            if (PassWordNew.Trim() == "" || user.Password.Trim() != PassWordNow) return null;
            return _dalUser.UpdatePassWord(user, PassWordNew);
        }
        public tbCustomer RegisterUser(string UserName,string Pass,string Fullname,string Tel,string Address)
        {
            if (Pass.Length < 1) return null;
            if (UserName.IndexOf(" ") != -1) return null;
            Fullname = Fullname.Trim();
            Tel = Tel.Trim();
            Address = Address.Trim();
            if(Pass==""||Fullname==""||Tel==""||Address=="") return null;
            return _dalUser.addUser(UserName, Pass, Fullname, Tel, Address);
        }
        public tbCustomer LoginUser(string UserName, String Pass)
        {
            if (UserName.IndexOf(" ") != -1) return null;
            if (Pass.Length < 1) return null;
            return _dalUser.getUser(UserName, Pass);
        }
        public tbCustomer LogOut()
        {
            return null;
        }
    }
}